<script setup>
import { inject, watch } from 'vue'

const msg = inject('msg')
watch(msg, (newVal, oldVal) => {
  console.log('son', newVal, oldVal)
})

const changeCountStr = inject('changeCount')
const changeCount = () => {
  changeCountStr()
}
</script>
<template>
  <div class="son">
    <h2>孙子组件</h2>
    <p>{{ msg }}</p>
    <button @click="changeCount">click</button>
  </div>
</template>

<style scoped>
.son {
  padding: 51px;
  border: 1px solid pink;
}
</style>
